#!/bin/bash
#function: auto install nodejs binary
#parmeter:
#author: yeslf
#version: 1.0 
#Test: CentOS 6 node-v6.14.2

cd /root

curl http://172.27.1.200/tool/nodjs/nodejs/6/node-v6.14.2-linux-x64.tar.gz>node-v6.14.2-linux-x64.tar.gz

ls -1 node-* |head -1 |xargs  tar -zxf

tarnode=$(ls -l   |grep ^d |awk '{print $9}') 


if [ $? != 0 ]
then
    echo "have no node programe file "
    exit 1 
fi


mv $tarnode /usr/local
for i in /usr/local/$tarnode/bin/*; do ln -s  $i /usr/bin/; done
ln -s /usr/local/$tarnode/include/node /usr/include/
ln -s  /usr/local/$tarnode/lib/node_modules /usr/lib/
ln -s  /usr/local/$tarnode/share/man/man1/node.1 /usr/share/man/man1/

ldconfig 

echo "install binnary node finish"

